3. signal management 3

好的,现在我们需要进入信号管理功能块的部分来管理重置。
OK, so now we need to ride to the part of the signal management function block to manage the reset.

因此,我只需要在此处的虚构中添加两个小修改,因为如果当前列表已饱和(这意味着它已满),我们将能够接受新信号。
So let's I will need to add just two small modifications in the fiction here, because we will be able to accept new signals if the current the list is in saturated, meaning that it is in full.

因此,这里激活允许任何信号的另一个条件是列出的信号,激活信号的数量低于信号的大小,这对我们 20 来说更容易。
So another condition here to activate to allow any signal is to have the signal listed that the number of active signals lower than the size of the signal, that is easier for us 20.

因此,如果我们的活动信号少于 20 个,我们实际上可以允许新信号在列表中弹出。
So if we have less than 20 active signals, we can actually allow new signals to pop up in the list.

否则,我们无法接受他们。
Otherwise, we are not able to accept them.

好的。
OK.

那么接下来,让我们看看如何处理信号的重置。
So moving on here, let's see how can we handle the reset of a signal so.

为了重置信号,首先,我们需要使非信号处于活动状态,因此信号必须不再处于活动状态。
In order to reset the signal, first of all, we need to have the not signal active, so the signal must be no longer active.

所以影响到。
So the impact to.

必须为假,并且我们需要已经将信号记录为活动状态,否则我们将重置为我们根本没有放置的信号。
Must be false, and we need to have already recorded the signal as active because otherwise we will be resetting as a signal that we didn't place in the least.

因此,为了看到这一点,我们需要在此处看到信号的活动信号,因为当我们激活信号时,我们会将其放置通过。
So in order to see that, we need to see active signals of signal into this area here, since when we activate the signal, we place it through.

当我们重置它时,我们将继续强制,但我们需要查看它以确保它已激活。
When we will reset it, we will proceed to force, but we need to look at it to be sure that it is activated.

然后我们还需要重置按钮或者在Stata中,如果我们有一个小时重置信号。
Then we also need the reset button or in Stata, if we have an hour to reset signal.

我们只需要解决这个问题,这意味着自动重置将在其变为 false 时简单地重置,而重置将需要一个不具有自动重置的信号,而我们需要按下实际的重置按钮。
We just need this to be settled through, this means that an auto reset that will simply reset whenever this becomes false, while instead the reset will need a signal that doesn't have the auto reset we need for the actual reset button to be pressed.

所以这里我们可以写我们需要重置或者外部重置。
So here we can write that we need the reset or the outer reset then.

这是正确的。
That's right.

就在这个这里。
And in the this here.

在这里,我们需要做的就是让信号从列表中消失。
Here, what we need to do, we need to make the signal disappear from the list.

所以。
So.

首先,我们需要重新排序列表,所以。
First of all, we will need to reorder the list, so.

从,嗯,我们正在重置它之后的所有信号开始,我们正在设置,我们需要所有这些信号都向上移动。
Starting from, um, all the signals that are after the one that we are resetting it, we are setting, we need all of them to move up.

将它们运送离开一个单位。
To ship them left by one unit.

因此,我们将在这里写的内容是,我们将对列表进行重新排序,并将其写入等于信号所在索引的索引。
So what we will write here, your we will reorder the list and we will write that for our index equal to the index in which the our signal is.

所以我们有这个。
So we have this.

通过这个数组,所以从我们的信号所在的索引到活动信号的数量信号,活动信号的数量减一,因为既然我们正在重置这个信号,我们将得到活动信号的数量,呃,减少一。
Via this array for that, so from the index in which our signal is to the number of active signals signal the number of active signals minus one, because since we are resetting this signal, we will get the number of active signals will, uh, be decreased by one.

我们需要做以下事情。
We need to do the following.

我们需要移动信号,所以在这里我们将编写最佳信号列表。
We need to shift the signals, so here we will write the best signal list.

索引的有效信号将等于下一个。
Active signals of index would become equal to the next one.

因此,信号少于索引的活跃信号加一,我们需要纠正。
So signal less that active signals of index plus one and we need to correct.

这个数组,信号数组,列表中的索引,为了做到这一点,我们只需要使用我们在前面的 VBA 中使用的同一行。
This array, the array of signals, indexes in the list, and in order to do so, we just need to use the same line that we used in the previous VBA.

这个。
This one.

这样,我们将修正信号指标,并将所有指标移回原处,接收到所有信号,返回信号并买入一个仓位。
In this way, we will correct the signal indexes and we will shift all the indexes back, received all the signals, signals back and buy one position.

因此,位于位置 6 的信号,如果我们重置,比如说信号 5,位于位置 6 的信号将获得位置 5。
So the signals that was in position six, if we reset, let's say signal five, the signal was in position six will get the position five.

信号是七点钟。
The signal was in seven.

我们将参加六场比赛,依此类推。
We'll get in six and so on.

然后我们需要以与此处相同的方式更新数字,以便我们可以复制它。
Then we need to update the numbers in the same way that we did here so we can copy this.

这部分代码在这里。
This part of the code here.

因此活动信号的数量将减少 1。
So the number of active signals will decrease by one.

我们实际上需要摆脱它,因为我们在这里没有使用它,并且根据警报,我们将减少信号类型。
We need to actually get rid of this because we are not using it here and according to the alert, to the type of signal we will decrease.

相应的计数器减一。
The corresponding counter by one.

然后,既然我们是这样,我们就改变了。
Then, since we are, we have shifted.

所有信号均一。
All the signals by one.

最后一个信号需要重置,因此如果我们将其置于此之前,我们将有 10 个活动信号,在此之后我们将有 9 个。
The last one will need to be reset, so if if we placed we before this, we had 10 active signals, after this we will have nine.

所以我们把它们全部移回去。
So we shifted all them back.

但在数组的第 10 个单元格中,我们仍然会有一些东西。
But in the 10th cell of the array, we will still have something.

因此,为了重置它,我们需要最早重置最后一个信号,并且我们将写入活动信号的信号列表。
So in order to reset this, we will need to reset last signal in the earliest and we will write signal list that active signals of.

活跃信号的数量加一,因为我们已经减少了,它减少了,看到一个列表,活跃信号的数量加一。
The number of active signals, plus one, because we have already decreased, it decreased, it's seen a list, that number of active signals plus one.

信号名称将变为空,所以我们将这样写。
That the signal name shall become empty, so we will write this.

我将复制这部分,在这里我们将得到。
I will copy this part and here we will have the.

Signalized 变为等于 0,并且信号类型应变为等于 none,并且活动值应变为等于force。
Signalized become equal to zero, and the signal type should become equal to none, and the active values should become equal to force.

然后我们需要做的最后一件事就是重置该数组的值。
Then the last thing that we need to do is to reset the value of this array.

因此,让我们复制这个,最后,自从我们切除信号以来,信号的活动信号。
So let's copy this, the end, the active signals of the signal already since we resected the signal.

我们可以设置为假吗?
Shall we set the false.

和。
And.

这个数组,这个信号索引是一个索引列表,因为我们正在停用与此相对应的信号。
This array, this signal index is an index list, since we are deactivating the signal corresponding to this the.

该值应设置为零。
This one should be set to zero.

好的,我们应该可以出发了。
OK, so we should be good to go.

让我们试试这个。
Let's try this.

那么我们就上网下载吧。
So let's go online and download.

让我们在右侧打开全局变量列表。
Let's open our global variable list here on the right.

有几个信号。
With a few signals.

让我们先讲一秒钟。
And so let's go for one second of line and.

哦,是的,一切都已经恢复正常,所以我们会看到它。
Oh, yeah, everything was already out of reset, so we will see it.

因此,让我们扩展一些索引的列表,并首先激活一个警报,抱歉程序现在正在循环。
So let's expand the list for a few indexes and let's start by activating an alarm sorry that the program is cycling right now.

对不起。
Sorry.

为了那个原因。
For that.

好的,我设置了一个已停用的闹钟,它消失了,这很好,因为我们现在必须重置。
OK, I set an alarm that's deactivated, it disappeared, this is good because we have now to reset.

如果我们没有一个小时的时间来重置,我们将需要重置命令。
If we didn't have an hour to reset, we will need the reset command.

因此,让我们添加第二个警报,让我们重置为第一个警报,如果重置第一个警报,我们将需要看到第二个警报回到位置一。
So let's add a second alarm, let's reset to the first one, if we reset the first one, we will need to see the second one get back to position one.

是的,这个应用程序,这确实有效,并且在信号索引数组中,我希望 C 位置为一。
Yes, this app, this actually worked and in the signal indexes array, I expect that the C position one.

所以,我的意思是,第二个萨尔瓦多没有人,是的,这有效,所以让我们进行一些测试。
So, I mean, no one at this second Salvadore, yes, this works, so let's carry out a few test.

让我们添加一个警告。
Let's add a warning.

这里应该会弹出警告。
Warning should pop up here.

那是对的。
That is correct.

让我们添加一个闹钟。
Let's add an alarm.

这里就正确弹出了。
Here it popped up correctly.

让我们删除第二个警报。
Let's remove the second alarm.

是的,一切都发生了变化,向上移动,表明新的警报。
Yes, everything shifted, was shifted upwards that said a new alarm.

是的,它似乎对我们来说工作得很好。
Yes, it seems to work quite fine for us.

我添加了一个新警告。
I added a new warning.

我收到一条新消息。
I had a new message.

如果我重置警告,并且要设置闹钟,则消息需要向上移动。
If I reset a warning, the message needs to shift up if I were to set an alarm.

好吧,警告和消息需要向上移动,是的,所以我们实际上设法编写了一个可以管理所有内容的紧凑块。
Well, warning and the message needs to shift up, yes, so we actually managed to write a compact block that will manage everything.

所以我们只需要为我们机器中的每个警报使用这个。
So we just simply need this for every alarm that we have in our machine.

这是一个非常强大的工具,我们可以直接在我们的机器上实现。
And this is a quite powerful tool that we can directly implement in our machine.

我们只进行修改以使其更加灵活,因为到目前为止,我们将一些数字硬编码到功能块中。
Let's only carry out a modification to make it more flexible because up to now, we hardcoded some numbers into the function block.

在这里,我们写道,我们只能有 1000 个活动信号,这对于我们的应用程序和信号列表中的漏洞来说可能太少或太多。
Here we wrote that we can have only 1000 active signals and this may be too few or too many for our application and the holes in our signal list.

我写道我们最多可以有 20 个。
I wrote that we can have up to 20.

当代活跃信号。
Contemporary active signals.

因此,为了避免这里出现这些数字,这实际上可能会阻止我们进入某种应用程序,我想让这是一些可配置的常量。
So in order to avoid these numbers here, that may actually stop us in kind of some kind of applications, I want to make this is some configurable constants.

因此,在我们的成本中,呃,用语言表达的全球化全局变量,我将有一个非常全局的常量来添加一些常量,以便使这 20 中的 1000,嗯,b 使您能够通过简单地更改变量来设置它。
So in our cost, uh, globalised global variable verbalised I will had a very global constant to add some constants in order to make this one thousand in this twenty, um, b make you able to set it by simply changing a variable.

所以我会在这里写下呃,同时,呃,橘子信号的最大数量。
So I will write here a maximum number of uh, of simultaneous with, uh, tangelos signals.

它应该是一个无符号整数,他们说它等于 20,我还将创建一个没有最大数量的可配置信号,这应该等于 1000。
It should be an unsigned integer, and they say that it is equal to 20 and I will create also a no maximum number of configurable signals and this should be equal to 1000.

因此,让我们替换所有 20 个,替换一个在寒冷的地方。
So let's replace all the 20 that replaced one was here in the cold.

另一个是这里数组的大小。
The other one was in the size of the array here.

让我们替换所有的一千个,让我们在这里替换这个,其他的是这里的本地声明。
And let's replace all the one thousand, let's replace this here and the other ones were the local declaration here.

因为通过这种方式,假设您想要一个列表而不是 20 个信号,您希望浪费更少的内存并且最大同时信号数为 10 个。
Because in this way, let's say you wanted to have a list instead of 20 signals, you wanted to waste less memory and have a maximum simultaneous number of signals of 10.

如果您执行下载,您实际上会看到列表大小发生变化,或者说 10 个对您来说太少了。
If you carry out a download, you will actually see your list changing size or let's say that 10 are too few for you.

假设您可能希望允许最多 100 个同步信号。
Let's say that you are you may want to allow up to 100 simultaneous signals.

您可以写 100,列表的大小将自行改变。
You can write 100 and your size of the list will change on its own.

这样您就可以配置它,而无需更改代码中的所有内容。
And this way you will be able to configure it without having to change everything in your code.

这使它再次变得非常强大。
And this makes it quite powerful again.

因此,如果您需要管理异常、警报和信息,这实际上对您非常有帮助,这种情况每次都会发生。
So this would be actually very helpful to you if you need to manage exceptions and alarm and information, this happens for every time.

因此,您不必每次都编写自定义代码,只需调用代码,FBI 实例化它,它将自行管理一切。
So instead of having to write custom code every time, you can simply call the code, this FBI instantiate it and it will manage everything on its own.

在下一个视频中,我们将开始在我们的机器项目中实现这一点。
In the next video, we will start implementing this in our machine project.